package com.muyu.cloud.commodity.controller;

import com.muyu.cloud.commodity.domain.model.Brand;
import com.muyu.cloud.commodity.service.BrandService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.security.annotation.RequiresPermissions;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/product/brand")
@Tag(name = "BrandController", description = "品牌管理")
public class BrandController {

    @Autowired
    private BrandService brandService;

    /**
     * 品牌的下拉框（管理端）
     * @return
     */
    @Operation(summary = "启用品牌下拉（管理端）")
    @RequiresPermissions("product:brand:list")
    @GetMapping("/enabled")
    public Result<List<Brand>> listEnabled() {
        return Result.success(brandService.listEnabled());
    }

    /**
     * 品牌的下拉框（公开接口，无需认证）
     * @return
     */
    @Operation(summary = "启用品牌下拉（公开接口）")
    @GetMapping("/public/enabled")
    public Result<List<Brand>> publicListEnabled() {
        return Result.success(brandService.listEnabled());
    }
}


